iT邦幫忙

2025 iThome 鐵人賽

DAY 2
0
Vue.js

Vue.js 新手入門之路系列 第 2

Vue.js 新手入門之路 - Node.js 與 Vite

  • 分享至 

  • xImage
  •  

今天要來試著將開發環境準備好
要下載的有

Vite 是一個 Javascript 建構工具

  • 可當 server
  • 只載入需要的檔案 -> 啟動快

還有很多優點,這邊就不再多贅述

首先要先來安裝 Node ,裡面的 npm 套件管理工具會一起下載好
Node.js 是讓 JavaScript 可以在瀏覽器外執行的環境,而 npm 則是管理專案的工具箱。

https://ithelp.ithome.com.tw/upload/images/20250822/2017829672Fo9QX9PY.png
基本上也是持續 next ,好了就按 Finish

接下來就可以在 VScode 裡面測試
https://ithelp.ithome.com.tw/upload/images/20250822/201782960blsVNhPul.png
先新增一個資料夾,然後在終端機 (Terminal) 裡面打指令就可以看到目前安裝的版本

node -v
npm -v

https://ithelp.ithome.com.tw/upload/images/20250822/20178296rtuirU939p.png

接下來就正式開始囉

執行

npm init vite@latest 

要輸入 y 再按 enter
https://ithelp.ithome.com.tw/upload/images/20250822/20178296Es298wYfCs.png

輸入專案名稱
https://ithelp.ithome.com.tw/upload/images/20250822/20178296442Atx3lm5.png

framework 這邊選擇 Vue
https://ithelp.ithome.com.tw/upload/images/20250822/20178296SuVauTGRty.png

接者選 Javascript
https://ithelp.ithome.com.tw/upload/images/20250822/20178296O4TOjcUSvT.png

就可以在資料夾內看到 Vite 自動幫我們建立好的檔案
https://ithelp.ithome.com.tw/upload/images/20250822/20178296Z1HwYgQsKw.png

接下來 cd 到專案裡面,cd 是 change directory 的意思

cd 剛剛取的專案名

https://ithelp.ithome.com.tw/upload/images/20250822/20178296PgeupQHJgP.png
如果懶得打,可以跟我一樣按 Tab
這邊偷教一個指令,有興趣的人可以自己玩,看會發生什麼事

cd..

安裝 Node 相關套件

npm install

https://ithelp.ithome.com.tw/upload/images/20250822/201782962kmB2Ys1ms.png

接下來就能試著開啟專案了!

npm run dev

https://ithelp.ithome.com.tw/upload/images/20250822/20178296XadkXz4rcA.png

Ctrl 按住再按藍色的 localhost 就能在瀏覽器畫面看到範例專案開起來了
https://ithelp.ithome.com.tw/upload/images/20250822/20178296VoXD2jijqb.png
Ctrl + C 就可以退出開發者伺服器

今天的進度就先到這邊,明天應該就會正式進入寫程式環節了

ref:
https://hackmd.io/@Jui-Cheng/SJCDBNZYj
https://www.youtube.com/watch?v=t7Px_M4SbRQ
https://www.youtube.com/watch?v=zwvUAh91itA
https://realnewbie.com/basic-concent/why-developers-are-switching-to-vite-the-ultimate-react-dev-tool/#ftoc-heading-3
https://www.explainthis.io/zh-hant/swe/what-is-vite


上一篇
Vue.js 新手入門之路 - Vue.js 是什麼 ? 能吃嗎 ?
下一篇
Vue.js 新手入門之路 - Hello! Vue
系列文
Vue.js 新手入門之路18
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言